# 路由
#


from flask import Flask

app = Flask(__name__)

# 路由配置

@app.route('/hello',methods=['GET','POST'])
def hello():
    return "Hello, World!++"

@app.route('/hi',methods=['POST'])
def hi():
    return "hi"

# 路由变量匹配规则
@app.route('/user/<id>')
def index(id):
    if id == '1':
        return "py1"
    if id == str(2):
        return "py2"
    if int(id) == 3:
        return "py3"
    return 'default'

# 直接传来int路径
# string不含斜杠的文本
# float浮点数
# path含有斜杠的文本
# int正整数
@app.route('/data/<int:ids>')
def index2(ids):
    if ids == 4:
        return "py4 int"
    if ids == 5:
        return "py5 int"
    return 'index'

if __name__ == '__main__':
    app.run()

